package com.sisy.dubboservice;

import com.sisy.common.AccountService;
import com.sisy.exception.BaseException;
import com.sisy.mapper.OrderMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @author EJ
 * @date 2021-06-14 08:42
 */
@Service("accountService")
public class AccountServiceImpl implements AccountService {
    @Autowired
    private OrderMapper orderMapper;

    @Override
    public String debitMoney(String userId, Integer money) {
        // 扣费
        int accountStatus = orderMapper.updateAccountMoney(money, userId);
        if (accountStatus == 0) {
            throw new BaseException("余额不足");
        }
        return "SUCCESS";
    }
}
